home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / pmake / customs / rpc.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-11-15  |  5.0 KB  |  147 lines

  1. /*-
  2.  * rpc.h --
  3.  *    Declarations required by users of the rpc module.
  4.  *
  5.  * Copyright (c) 1988, 1989 by the Regents of the University of California
  6.  * Copyright (c) 1988, 1989 by Adam de Boor
  7.  * Copyright (c) 1989 by Berkeley Softworks
  8.  *
  9.  * Permission to use, copy, modify, and distribute this
  10.  * software and its documentation for any non-commercial purpose
  11.  * and without fee is hereby granted, provided that the above copyright
  12.  * notice appears in all copies.  The University of California,
  13.  * Berkeley Softworks and Adam de Boor make no representations about
  14.  * the suitability of this software for any purpose.  It is provided
  15.  * "as is" without express or implied warranty.
  16.  *
  17.  *    "$Id: rpc.h,v 1.11 89/11/14 13:46:30 adam Exp $ SPRITE (Berkeley)"
  18.  */
  19. #ifndef _RPC_H_
  20. #define _RPC_H_
  21.  
  22. /*
  23.  * Beware! Some systems are brain-dead when it comes to sys/types...
  24.  */
  25. #include    <sys/types.h>
  26.  
  27. /*
  28.  * Boolean arguments
  29.  */
  30. #define True      1
  31. #define False      0
  32.  
  33. #ifndef Boolean
  34. #define Boolean      int
  35. #endif Boolean
  36.  
  37. /*
  38.  * Define macros for select bitmap manipulation. What this will do on
  39.  * systems that don't allow this many open descriptors, I don't know.
  40.  */
  41. #ifndef FD_SET
  42.  
  43. #define    NBBY    8        /* number of bits in a byte */
  44. /*
  45.  * Select uses bit masks of file descriptors in longs.
  46.  * These macros manipulate such bit fields (the filesystem macros use chars).
  47.  * FD_SETSIZE may be defined by the user, but the default here
  48.  * should be >= NOFILE (param.h).
  49.  */
  50. #ifndef    FD_SETSIZE
  51. #define    FD_SETSIZE    256
  52. #endif
  53.  
  54. typedef long    fd_mask;
  55. #define NFDBITS    (sizeof(fd_mask) * NBBY)    /* bits per mask */
  56. #ifndef howmany
  57. #define    howmany(x, y)    ((unsigned int)(((x)+((y)-1)))/(unsigned int)(y))
  58. #endif
  59.  
  60. typedef    struct fd_set {
  61.     fd_mask    fds_bits[howmany(FD_SETSIZE, NFDBITS)];
  62. } fd_set;
  63.  
  64. #define    FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
  65. #define    FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
  66. #define    FD_ISSET(n, p)    ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
  67. #define FD_ZERO(p)    bzero((char *)(p), sizeof(*(p)))
  68.  
  69. #endif /* FD_SET */
  70.  
  71. /*
  72.  * Flags for Rpc_Watch
  73.  */
  74. #define RPC_READABLE    1
  75. #define RPC_WRITABLE    2
  76. #define RPC_EXCEPTABLE    4
  77.  
  78. typedef unsigned short     Rpc_Proc;
  79. typedef void           *Rpc_Opaque;
  80.  
  81. typedef Rpc_Opaque      Rpc_Event;      /* Type returned by Rpc_EventCreate */
  82. typedef Rpc_Opaque      Rpc_Message;    /* Handle for replying to a call */
  83.  
  84. /*
  85.  * For prefix's sunrpc module, we need to avoid defining this thing as an
  86.  * enumerated type, since Sun RPC uses these same names (funny how that works)
  87.  */
  88. #ifndef NO_RPC_STAT
  89. typedef enum {
  90.     RPC_SUCCESS,        /* Call succeeded, here's reply data */
  91.     RPC_CANTSEND,         /* Couldn't send message, for some reason */
  92.     RPC_TIMEDOUT,          /* Message timed out */
  93.     RPC_TOOBIG,              /* Results (or message) too big */
  94.     RPC_NOPROC,              /* No such procedure on remote machine */
  95.     RPC_ACCESS,              /* Permission denied */
  96.     RPC_BADARGS,          /* Arguments were improper */
  97.     RPC_SYSTEMERR,        /* Undefined system error */
  98. } Rpc_Stat;
  99. #else
  100. typedef int Rpc_Stat;
  101. #endif
  102.  
  103. /*
  104.  * Swapping definitions
  105.  */
  106. #define Rpc_SwapNull    ((void (*)())0)    /* Constant for no swapping */
  107. extern void      Rpc_SwapShort();      /* Swap a short integer (two bytes) */
  108. extern void      Rpc_SwapLong();       /* Swap a long integer (four bytes) */
  109.  
  110. /*
  111.  * Other definitions
  112.  */
  113. extern void      Rpc_ServerCreate();    /* Create a service on a socket */
  114. extern void      Rpc_ServerDelete();    /* Delete a service on a socket */
  115. extern Rpc_Event  Rpc_EventCreate();    /* Create a timer event */
  116. extern void      Rpc_EventDelete();    /* Delete a timer event */
  117. extern void      Rpc_EventReset();    /* Reset the time of an event */
  118. extern void      Rpc_Watch();        /* Watch a stream */
  119. extern void      Rpc_Ignore();       /* Ignore a stream */
  120. extern void      Rpc_Error();        /* Return an error to an RPC call */
  121. extern void      Rpc_Return();       /* Return a reply to an RPC call */
  122. extern Rpc_Stat   Rpc_Call();            /* Call a remote procedure */
  123. extern Rpc_Stat   Rpc_Broadcast();    /* Broadcast a call to a remote
  124.                      * procedure */
  125. extern void      Rpc_Wait();            /* Wait for something to happen */
  126. extern void      Rpc_Run();            /* Wait forever for something to
  127.                      * happen */
  128. extern int      Rpc_TcpCreate();    /* Create a TCP socket with a name */
  129. extern int      Rpc_UdpCreate();    /* Create a UDP socket with a name */
  130. extern void      Rpc_Debug();        /* Turn on debugging printouts */
  131. extern int      Rpc_MessageSocket();    /* Return the socket for a message */
  132. extern char      *Rpc_ErrorMessage();    /* Return a string describing an error
  133.                      * status */
  134. extern void      Rpc_Reset();        /* Reset the module, deleting all
  135.                      * services, timer events and watched
  136.                      * streams */
  137. extern Boolean      Rpc_IsLocal();        /* See if an internet socket address
  138.                      * is for the local machine */
  139.  
  140. extern fd_set      rpc_readMask;            /* Mask of streams to check for
  141.                      * reading */
  142. extern fd_set      rpc_writeMask;        /* Mask of streams to check for
  143.                      * writing */
  144. extern fd_set      rpc_exceptMask;       /* Mask of streams to check for an
  145.                      * exceptional condition */
  146. #endif _RPC_H_
  147.